package pro.softzhang.algo.lc6200;

import pro.softzhang.algo.flag.book.BWeekMatch;

@BWeekMatch(314)
public class LC6200_TheEmployeeThatWorkedOnTheLongestTask {
    public static void main(String[] args) {

    }

    static class Solution {
        /**
         n = 10, logs = [[0,3],[2,5],[0,9],[1,15]]
         */
        public int hardestWorker(int n, int[][] logs) {
            int worker = logs[0][0], time = logs[0][1];
            for(int i = 1; i < logs.length; i++) {
                int iTime = logs[i][1] - logs[i - 1][1];
                if(iTime > time) {
                    time = iTime;
                    worker = logs[i][0];
                    continue;
                }

                if(iTime == time) {
                    worker = Math.min(logs[i][0], worker);
                }
            }
            return worker;
        }
    }
}
